GOST (hash Function)
   HOME

TheInfoList



OR:

The GOST hash function, defined in the standards GOST R 34.11-94 and GOST 34.311-95 is a 256-bit
cryptographic hash function A cryptographic hash function (CHF) is a hash algorithm (a map of an arbitrary binary string to a binary string with fixed size of n bits) that has special properties desirable for cryptography: * the probability of a particular n-bit output re ...
. It was initially defined in the Russian national standard
GOST GOST (russian: ГОСТ) refers to a set of international technical standards maintained by the ''Euro-Asian Council for Standardization, Metrology and Certification (EASC)'', a regional standards organization operating under the auspices of th ...
R 34.11-94 ''Information Technology – Cryptographic Information Security – Hash Function''. The equivalent standard used by other member-states of the
CIS Cis or cis- may refer to: Places * Cis, Trentino, in Italy * In Poland: ** Cis, Świętokrzyskie Voivodeship, south-central ** Cis, Warmian-Masurian Voivodeship, north Math, science and biology * cis (mathematics) (cis(''θ'')), a trigonome ...
is GOST 34.311-95. This function must not be confused with a different
Streebog Streebog (russian: Стрибог) is a cryptographic hash function defined in the Russian national standard GOST R 34.11-2012 ''Information Technology – Cryptographic Information Security – Hash Function''. It was created to replace an obsol ...
hash function, which is defined in the new revision of the standard GOST R 34.11-2012.GOST R 34.11-2012: Streebog Hash Function
/ref> The GOST hash function is based on the
GOST block cipher The GOST block cipher (Magma), defined in the standard GOST 28147-89 (RFC 5830), is a Soviet and Russian government standard symmetric key block cipher with a block size of 64 bits. The original standard, published in 1989, did not give the ciphe ...
.


Algorithm

GOST processes a variable-length message into a fixed-length output of 256 bits. The input message is broken up into chunks of 256-bit blocks (eight 32-bit
little endian In computing, endianness, also known as byte sex, is the order or sequence of bytes of a word of digital data in computer memory. Endianness is primarily expressed as big-endian (BE) or little-endian (LE). A big-endian system stores the most sig ...
integers); the message is padded by appending as many zeros to it as are required to bring the length of the message up to 256 bits. The remaining bits are filled up with a 256-bit integer arithmetic sum of all previously hashed blocks and then a 256-bit integer representing the length of the original message, in bits.


Basic notation

The algorithm descriptions uses the following notations: * \mathcal0\mathcal^j — j-bit block filled with zeroes. * \mathcalM\mathcal — length of the M block in bits modulo 2256. * \mathcal — concatenation of two blocks. * + — arithmetic sum of two blocks modulo 2256 * \oplus — logical xor of two blocks Further we consider that the little-order bit is located at the left of a block, and the high-order bit at the right.


Description

The input message M is split into 256-bit blocks m_, m_, m_, ... , m_. In the case the last block m_ contains less than 256 bits, it is prepended left by zero bits to achieve the desired length. Each block is processed by the step hash function H_\ =\ f(H_, m), where H_, H_, m are a 256-bit blocks. Each message block, starting the first one, is processed by the step hash function f, to calculate intermediate hash value
\!H_=f(H_, m_)
The H_1 value can be arbitrary chosen, and usually is 0^. After H_ is calculated, the final hash value is obtained in the following way * H_\ =\ f(H_,\ L), where L — is the length of the message M in bits modulo 2^ * h\ =\ f(H_,\ K), where K — is 256-bit control sum of M: m_1 + m_2 + m_3 + ... + m_n The h is the desired value of the hash function of the message M. So, the algorithm works as follows. # Initialization: ## h\ := initial — Initial 256-bit value of the hash function, determined by user. ## \Sigma\ :=\ 0 — Control sum ## L\ :=\ 0 — Message length # Compression function of internal iterations: for i = 1 … n — 1 do the following (while , M, >256): ## h\ :=\ f(h,\ m_i) – apply step hash function ## L\ :=\ L\ +\ 256 – recalculate message length ## \Sigma\ :=\ \Sigma\ +\ m_i – calculate control sum # Compression function of final iteration: ## L\ :=\ L\ +\ \mathcal\ m_n\ \mathcal – calculate the full message length in bits ## m_n\ :=\ ^ \mathcal m_n – pad the last message with zeroes ## \Sigma\ :=\ \Sigma\ +\ m_n – update control sum ## h\ :=\ f(h,\ m_n) – process the last message block ## h\ :=\ f(h,\ L) – MD – strengthen up by hashing message length ## h\ :=\ f(h,\ \Sigma) – hash control sum # The output value is h.


Step hash function

The step hash function f maps two 256-bit blocks into one: H_\ =\ f(H_,\ m). It consist of three parts: * Generating of keys K_1,\ K_2,\ K_3,\ K_4 * Enciphering transformation \ H_ using keys K_1,\ K_2,\ K_3,\ K_4 * Shuffle transformation


Key generation

The keys generating algorithm uses: * Two transformations of 256-bit blocks: ** Transformation A(Y)=A(y_4\ \mathcal\ y_3\ \mathcal\ y_2\ \mathcal\ y_1) = (y_1 \oplus y_2)\ \mathcal\ y_4\ \mathcal\ y_3\ \mathcal\ y_2, where y_1,\ y_2,\ y_3,\ y_4 are 64-bit sub-blocks of ''Y''. ** Transformation P(Y) = P(y_ \mathcal y_ \mathcal \dots \mathcal y_1) = y_ \mathcal y_ \mathcal \dots \mathcal y_, where \varphi (i + 1 + 4(k - 1))= 8i + k,\ i = 0, \dots, 3,\ k = 1, \dots, 8, and y_,\ y_,\ \dots,\ y_ are 8-bit sub-blocks of ''Y''. * Three constants: ** ''C''2 = ** ''C''3 = ** ''C''4 = The algorithm: # U\ :=\ H_,\quad V\ :=\ m,\quad W\ :=\ U\ \oplus\ V,\quad K_1\ =\ P(W) # For ''j'' = 2,3,4 do the following: #: U := A(U) \oplus C_j,\quad V := A(A(V)),\quad W := U \oplus V,\quad K_j = P(W)


Enciphering transformation

After the keys generation, the enciphering of H_ is done using GOST 28147-89 in the mode of simple substitution on keys K_1, K_2, K_3, K_4. Let's denote the enciphering transformation as E (Note: the E transformation enciphers 64-bit data using 256-bit key). For enciphering, the H_ is split into four 64-bit blocks: H_ = h_4 \mathcal h_3 \mathcal h_2 \mathcal h_1 , and each of these blocks is enciphered as: * s_1 = E(h_1, K_1) * s_2 = E(h_2, K_2) * s_3 = E(h_3, K_3) * s_4 = E(h_4, K_4) After this, the result blocks are concatenated into one 256-bit block: S = s_4 \mathcal s_3 \mathcal s_2 \mathcal s_1.


Shuffle transformation

On the last step, the shuffle transformation is applied to H_, S and m using a
linear-feedback shift register In computing, a linear-feedback shift register (LFSR) is a shift register whose input bit is a linear function of its previous state. The most commonly used linear function of single bits is exclusive-or (XOR). Thus, an LFSR is most often a sh ...
. In the result, the intermediate hash value H_ is obtained. First we define the ψ function, doing
LFSR In computing, a linear-feedback shift register (LFSR) is a shift register whose input bit is a linear function of its previous state. The most commonly used linear function of single bits is exclusive-or (XOR). Thus, an LFSR is most often a sh ...
on a 256-bit block: \psi(Y) = \psi(y_ \mathcal y_ \mathcal ... \mathcal y_2 \mathcal y_1) = (y_1 \oplus y_2 \oplus y_3 \oplus y_4 \oplus y_ \oplus y_) \mathcal y_ \mathcal y_ \mathcal ... \mathcal y_3 \mathcal y_2, where y_, y_, ... , y_, y_ are 16-bit sub-blocks of the ''Y''. The shuffle transformation is H_ = ^(H_ \oplus \psi(m \oplus ^(S))), where ^i denotes an i-th power of the \psi function.


Initial values

There are two commonly used sets of initial parameters for GOST R 34.11 94. The starting vector for both the sets is H_1=0x00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000. Although the GOST R 34.11 94 standard itself doesn't specify the algorithm initial value H_1 and
S-box In cryptography, an S-box (substitution-box) is a basic component of symmetric key algorithms which performs substitution. In block ciphers, they are typically used to obscure the relationship between the key and the ciphertext, thus ensuring Sha ...
of the enciphering transformation E, but uses the following "test parameters" in the samples sections.


"Test parameters" S-box

RFC 5831 specifies only these parameters, but RFC 4357 names them as "test parameters" and does not recommend them for use in production applications.


CryptoPro S-box

The CryptoPro
S-box In cryptography, an S-box (substitution-box) is a basic component of symmetric key algorithms which performs substitution. In block ciphers, they are typically used to obscure the relationship between the key and the ciphertext, thus ensuring Sha ...
comes from "production ready" parameter set developed by CryptoPro company, it is also specified as part of RFC 4357, section 11.2.


Cryptanalysis

In 2008, an attack was published that breaks the full-round GOST hash function. The paper presents a
collision attack In cryptography, a collision attack on a cryptographic hash tries to find two inputs producing the same hash value, i.e. a hash collision. This is in contrast to a preimage attack where a specific target hash value is specified. There are roughl ...
in 2105 time, and first and second
preimage attack In cryptography, a preimage attack on cryptographic hash functions tries to find a message that has a specific hash value. A cryptographic hash function should resist attacks on its preimage (set of possible inputs). In the context of attack, th ...
s in 2192 time (2''n'' time refers to the approximate number of times the algorithm was calculated in the attack).


GOST hash test vectors


Hashes for "test parameters"

The 256-bit (32-byte) GOST hashes are typically represented as 64-digit hexadecimal numbers. Here are test vectors for the GOST hash with "test parameters" GOST("The quick brown fox jumps over the lazy og") = 77b7fa410c9ac58a25f49bca7d0468c9296529315eaca76bd1a10f376d1f4294 Even a small change in the message will, with overwhelming probability, result in a completely different hash due to the
avalanche effect In cryptography, the avalanche effect is the desirable property of cryptographic algorithms, typically block ciphers and cryptographic hash functions, wherein if an input is changed slightly (for example, flipping a single bit), the output changes ...
. For example, changing to : GOST("The quick brown fox jumps over the lazy og") = a3ebc4daaab78b0be131dab5737a7f67e602670d543521319150d2e14eeec445 Two samples coming from the GOST R 34.11-94 standard: GOST("This is message, length=32 bytes") = b1c466d37519b82e8319819ff32595e047a28cb6f83eff1c6916a815a637fffa GOST("Suppose the original message has length = 50 bytes") = 471aba57a60a770d3a76130635c1fbea4ef14de51f78b4ae57dd893b62f55208 More test vectors: GOST("") = ce85b99cc46752fffee35cab9a7b0278abb4c2d2055cff685af4912c49490f8d GOST("a") = d42c539e367c66e9c88a801f6649349c21871b4344c6a573f849fdce62f314dd GOST("message digest") = ad4434ecb18f2c99b60cbe59ec3d2469582b65273f48de72db2fde16a4889a4d GOST( 128 characters of 'U' ) = 53a3a3ed25180cef0c1d85a074273e551c25660a87062a52d926a9e8fe5733a4 GOST( 1000000 characters of 'a' ) = 5c00ccc2734cdd3332d3d4749576e3c1a7dbaf0e7ea74e9fa602413c90a129fa


Hashes for CryptoPro parameters

GOST algorithm with CryptoPro S-box generates different set of hash values. GOST("") = 981e5f3ca30c841487830f84fb433e13ac1101569b9c13584ac483234cd656c0 GOST("a") = e74c52dd282183bf37af0079c9f78055715a103f17e3133ceff1aacf2f403011 GOST("abc") = b285056dbf18d7392d7677369524dd14747459ed8143997e163b2986f92fd42c GOST("message digest") = bc6041dd2aa401ebfa6e9886734174febdb4729aa972d60f549ac39b29721ba0 GOST("The quick brown fox jumps over the lazy dog") = 9004294a361a508c586fe53d1f1b02746765e71b765472786e4770d565830a76 GOST("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = 73b70a39497de53a6e08c67b6d4db853540f03e9389299d9b0156ef7e85d0f61 GOST("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = 6bc7b38989b28cf93ae8842bf9d752905910a7528a61e5bce0782de43e610c90 GOST("This is message, length=32 bytes") = 2cefc2f7b7bdc514e18ea57fa74ff357e7fa17d652c75f69cb1be7893ede48eb GOST("Suppose the original message has length = 50 bytes") = c3730c5cbccacf915ac292676f21e8bd4ef75331d9405e5f1a61dc3130a65011 GOST(128 of "U") = 1c4ac7614691bbf427fa2316216be8f10d92edfd37cd1027514c1008f649c4e8 GOST(1000000 of "a") = 8693287aa62f9478f7cb312ec0866b6c4e4a0f11160441e8f4ffcd2715dd554f


See also

*
Kupyna Kupyna ( uk, Купина) is a cryptographic hash function defined in the Ukrainian national standard DSTU 7564:2014. It was created to replace an obsolete GOST hash function defined in the old standard GOST 34.11-95, similar to Streebog hash f ...
*
Hash function security summary This article summarizes publicly known cryptanalysis, attacks against cryptographic hash functions. Note that not all entries may be up to date. For a summary of other hash function parameters, see comparison of cryptographic hash functions. Tabl ...
*
GOST standards GOST (russian: ГОСТ) refers to a set of international technical standards maintained by the ''Euro-Asian Council for Standardization, Metrology and Certification (EASC)'', a regional standards organization operating under the auspices of th ...
*
List of hash functions This is a list of hash functions, including cyclic redundancy checks, checksum functions, and cryptographic hash functions. Cyclic redundancy checks Adler-32 is often mistaken for a CRC, but it is not: it is a checksum. Checksums Universa ...


References


Further reading

* * The full text of the GOST R 34.11-94 standard (in Russian).


External links


C implementation and test vectors
for GOST hash function from Markku-Juhani Saarinen, also contains draft translations into English of the GOST 28147-89 and GOST R 34.11-94 standards. Bugfixed version, se


C++ implementation with STL streams

RHash
an
open source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
command-line tool, which can calculate and verify GOST hash (supports both parameter sets).
Implementation of the GOST R 34.11-94 in JavaScriptCryptoPro parameters

The GOST Hash Function Ecrypt page

Online GOST Calculator
{{DEFAULTSORT:Gost (Hash Function) Broken hash functions Cryptographic hash functions GOST standards